<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<c:set var="grant_code">
	<x:out select="$xmlData/data/proposal/grant_code" />
</c:set>
<c:set var="sub_grant_code">
	<x:out select="$xmlData/data/proposal/sub_grant_code" />
</c:set>

<div class="t_bar">
	<span class="color_red">*</span>经费投入情况（单位：万元）
</div>
<table class="t_css" width="100%" border="0" cellpadding="0"
	cellspacing="1"  id="budgetsMsg">
	<tr>
		<td  nowrap align="right">项目计划投资总额：</td>
		<td ><input type="text" style="text-align: right;width: 100px"
			name="budgets/input_total" id="source_total"
			class="gray " disabled
			label="经费投入情况-->项目计划投资总额" 
			value="<x:out select="$xmlData/data/budgets/input_total" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		<td  nowrap align="right">已完成投资：</td>
		<td><input type="text" style="text-align: right;width: 100px"
			name="budgets/already_input_total" id="source_already"
			class="required gray" label="经费投入情况-->已完成投资" disabled
			value="<x:out select="$xmlData/data/budgets/already_input_total" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		<td  nowrap align="right">计划新增投资：</td>
		<td ><input type="text" style="text-align: right;width: 100px"
			name="budgets/add_research" id="source_add"
			class="required gray valueEqual:source_add:total_1" disabled
			label="经费投入情况-->计划新增投资"
			value="<x:out select="$xmlData/data/budgets/add_research" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		<td align="right"><span class="color_red">*</span>申请金额：</td>
		<td ><input type="text"
			style="text-align: right;width: 100px" name="budgets/apply_money"
			id="source_apply" class="required  valueEqual:source_apply:total_2" label="经费投入情况-->申请金额"
			onchange="setSource(this.value);countFundAuto('source_','own,bank,other,country,provincial,city,area','add');countFundAuto('source_','already,add','total');synchro();"
			value="<x:out select="$xmlData/data/budgets/apply_money" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>



	</tr>
</table>
<br/>
<div class="t_bar">
	<span class="color_red">*</span>已完成投资来源（单位：万元）
</div>
<table class="t_css" width="100%" border="0" cellpadding="0"
	cellspacing="1"  id="budgetsMsg1">
	<tr align="center" class="li_2">
		<td rowspan="2">自有资金</td>
		<td rowspan="2">银行贷款</td>
		<td colspan="4">已获政府资金</td>
		<td rowspan="2" >其他资金</td>
	</tr>
	<tr align="center" class="li_2">
		<td>国家</td>
		<td>省级</td>
		<td>市级</td>
		<td>区级</td>
	</tr>
	<tr class="li_1">
		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/own_fund_over" id="source_own_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="已完成投资来源-->自有资金"
			value="<x:out select="$xmlData/data/budgets/own_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/bank_fund_over" id="source_bank_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="已完成投资来源-->银行贷款"
			value="<x:out select="$xmlData/data/budgets/bank_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

	

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/country_fund_over" id="source_country_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="已完成投资来源-->已获政府资金（国家）"
			value="<x:out select="$xmlData/data/budgets/country_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/provincial_fund_over" id="source_provincial_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="已完成投资来源-->已获政府资金（省级）"
			value="<x:out select="$xmlData/data/budgets/provincial_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/city_fund_over" id="source_city_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');countFundAuto('source_','already,add','total');synchro();"
			class="required " label="已完成投资来源-->已获政府资金（市级）"
			value="<x:out select="$xmlData/data/budgets/city_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/area_fund_over" id="source_area_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="已完成投资来源-->已获政府资金（区级）"
			value="<x:out select="$xmlData/data/budgets/area_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		
	<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/other_fund_over" id="source_other_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');countFundAuto('source_','already,add','total');synchro();"
			class="required " label="已完成投资来源-->其他资金"
			value="<x:out select="$xmlData/data/budgets/other_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>	
			
	</tr>

</table>
<br/>
<div class="t_bar">
	<span class="color_red">*</span>计划新增投资来源（单位：万元）
</div>
<table class="t_css" width="100%" border="0" cellpadding="0"
	cellspacing="1"  id="budgetsMsg2">
	<tr align="center" class="li_2">
		<td rowspan="2">自有资金</td>
		<td rowspan="2">银行贷款</td>
		<td colspan="4">申请政府资金</td>
		<td rowspan="2" >其他资金</td>
	</tr>
	<tr align="center" class="li_2">
		<td>国家</td>
		<td>省级</td>
		<td>市级</td>
		<td>区级</td>
	</tr>
	<tr class="li_1">
		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/own_fund" id="source_own"
			onchange="countFundAuto('source_','own,bank,other,country,provincial,city,area','add');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="计划新增投资来源-->自有资金"
			value="<x:out select="$xmlData/data/budgets/own_fund" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/bank_fund" id="source_bank"
			onchange="countFundAuto('source_','own,bank,other,country,provincial,city,area','add');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="计划新增投资来源-->银行贷款"
			value="<x:out select="$xmlData/data/budgets/bank_fund" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

	

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/country_fund" id="source_country"
			onchange="countFundAuto('source_','own,bank,other,country,provincial,city,area','add');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="计划新增投资来源-->申请政府资金（国家）"
			value="<x:out select="$xmlData/data/budgets/country_fund" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/provincial_fund" id="source_provincial"
			onchange="countFundAuto('source_','own,bank,other,country,provincial,city,area','add');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="计划新增投资来源-->申请政府资金（省级）"
			value="<x:out select="$xmlData/data/budgets/provincial_fund" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/city_fund" id="source_city"
			onchange="countFundAuto('source_','own,bank,other,country,provincial,city,area','add');countFundAuto('source_','already,add','total');synchro();"
			class="required " label="计划新增投资来源-->申请政府资金（市级）"
			value="<x:out select="$xmlData/data/budgets/city_fund" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/area_fund" id="source_area"
			onchange="countFundAuto('source_','own,bank,other,country,provincial,city,area','add');countFundAuto('source_','already,add','total');synchro();"
			class="required" label="计划新增投资来源-->申请政府资金（区级）"
			value="<x:out select="$xmlData/data/budgets/area_fund" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		
	<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/other_fund" id="source_other"
			onchange="countFundAuto('source_','own,bank,other,country,provincial,city,area','add');countFundAuto('source_','already,add','total');synchro();"
			class="required " label="计划新增投资来源-->其他资金"
			value="<x:out select="$xmlData/data/budgets/other_fund" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>	
			
	</tr>

</table>
<br/>
<div class="t_bar">
	<span class="color_red">*</span>计划新增投资支出（单位：万元）
</div>
<table class="t_css" width="100%" border="0" cellpadding="0" cellspacing="1" id="tblInvests">
<thead >
	<tr >
	   <th class="TblHead" align="center"  width="5%">选择</th>
		<th class="TblHead" align="center"  width="5%">序号</th>
		<th class="TblHead" align="center" width="30%" >平台名称</th>
		<th class="TblHead" align="center" width="15%">总额</th>
		<th class="TblHead" align="center" width="15%">其中：申请资助经费</th>
		<th class="TblHead" align="center" width="10%" >${year}年</th>
		<th class="TblHead" align="center" width="10%" >${year+1}年</th>
		<th class="TblHead" align="center" width="10%" >${year+2}年</th>
	</tr>
	</thead>

			<tbody id="tab">
					<tr style="display:none" align="center">
						<td align="center">&nbsp;<input type="radio" class="radiobutton" name="selInvests" ></td>
						<td align="center">&nbsp;<span name="invests|invest[0]@seq_no" >[index]</span></td>
						<td align="center"><input type="text" name="invests|invest[0]|name" label="平台名称" class=" required input_text " maxlength="100" style="width:80%"/></td>
						<td align="center"><input type="text" name="invests|invest[0]|total_invest"  onchange="countTable('tblInvests','total_1',3);" id="total_invest_[0]" label="总额" onfocus="InitInput.setNumber(this,7,4,2)"   style="text-align:right;width:80%" class=" input_text required " /></td> 
						<td align="center"><input type="text" name="invests|invest[0]|apply_invest"  onchange="countTable('tblInvests','total_2',4);" id="apply_invest_[0]" label="其中：申请资助经费" onfocus="InitInput.setNumber(this,7,4,2)" style="text-align:right;width:80%" class=" input_text required valueGreatEqual:total_invest_[0]:apply_invest_[0]" /></td>
						<td align="center"><input type="text" name="invests|invest[0]|this_invest"  onchange="countTable('tblInvests','total_3',5);" id="this_invest_[0]" label="${year}年预算" onfocus="InitInput.setNumber(this,7,4,2)" style="text-align:right;width:80%" class=" input_text required valueGreatEqual:total_invest_[0]:this_invest_[0]" /></td>
						<td align="center"><input type="text" name="invests|invest[0]|next_invest"  onchange="countTable('tblInvests','total_4',6);" id="next_invest_[0]" label="${year+1}年预算" onfocus="InitInput.setNumber(this,7,4,2)" style="text-align:right;width:80%" class=" input_text required valueGreatEqual:total_invest_[0]:next_invest_[0]" /></td>
						<td align="center"><input type="text" name="invests|invest[0]|after_invest"  onchange="countTable('tblInvests','total_5',7);" id="after_invest_[0]" label="${year+2}年预算" onfocus="InitInput.setNumber(this,7,4,2)" style="text-align:right;width:80%" class=" input_text required valueGreatEqual:total_invest_[0]:after_invest_[0]" /></td>
						
					</tr>
					
					<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/invests/invest" var="invest">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr align="center">
						<td align="center">&nbsp;<input type="radio" class="radiobutton" name="selInvests" ></td>
						<td align="center">&nbsp;<span name="invests/invest[${flag}${index}]@seq_no" ><x:out select="$invest/@seq_no"/></span></td>
						<td><input type="text" name="invests/invest[${flag}${index}]/name"  label="平台名称" style="width:80%"   class=" input_text required" value="<x:out select="$invest/name" />" maxlength="100"/></td>
						
						<td >
							<input type="text" name="invests/invest[${flag}${index}]/total_invest"  id="total_invest_[${flag}${index}]" onchange="countTable('tblInvests','total_1',3);"  label="总额"  onfocus="InitInput.setNumber(this,7,4,2)"   style="text-align:right;width:80%"  class=" input_text required" value="<x:out select="$invest/total_invest" />"/>
						</td> 
						<td >
							<input type="text" name="invests/invest[${flag}${index}]/apply_invest"  id="apply_invest_[${flag}${index}]" onchange="countTable('tblInvests','total_2',4);" label="其中：申请资助经费"  onfocus="InitInput.setNumber(this,7,4,2)"   style="text-align:right;width:80%"  class=" input_text required valueGreatEqual:total_invest_[${flag}${index}]:apply_invest_[${flag}${index}]" value="<x:out select="$invest/apply_invest" />"/>
						</td> 
						<td >
							<input type="text" name="invests/invest[${flag}${index}]/this_invest"  id="this_invest_[${flag}${index}]" onchange="countTable('tblInvests','total_3',5);" label="${year}年预算"  onfocus="InitInput.setNumber(this,7,4,2)"   style="text-align:right;width:80%"  class=" input_text required valueGreatEqual:total_invest_[${flag}${index}]:this_invest_[${flag}${index}]" value="<x:out select="$invest/this_invest" />"/>
						</td> 
						<td >
							<input type="text" name="invests/invest[${flag}${index}]/next_invest"  id="next_invest_[${flag}${index}]" onchange="countTable('tblInvests','total_4',6);" label="${year+1}年预算"  onfocus="InitInput.setNumber(this,7,4,2)"   style="text-align:right;width:80%"  class=" input_text required valueGreatEqual:total_invest_[${flag}${index}]:next_invest_[${flag}${index}]" value="<x:out select="$invest/next_invest" />"/>
						</td> 
						<td >
							<input type="text" name="invests/invest[${flag}${index}]/after_invest"  id="after_invest_[${flag}${index}]" onchange="countTable('tblInvests','total_5',7);" label="${year+2}年预算"  onfocus="InitInput.setNumber(this,7,4,2)"   style="text-align:right;width:80%"  class=" input_text required valueGreatEqual:total_invest_[${flag}${index}]:after_invest_[${flag}${index}]" value="<x:out select="$invest/after_invest" />"/>
						</td> 
					</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					</x:forEach>
					
				</tbody>
					</table>
					<table   cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
					<tr align="center">
					<td colspan="3" width="40%">合计</td>
					<td width="15%"><input name="invests/total_1" id="total_1" value="<x:out select="$xmlData/data/invests/total_1" />" class="gray input_text"  disabled style="text-align:right;width:80%;" label="计划新增投资支出总额合计" onfocus="InitInput.setNumber(this,7,4,2)" /></td>
                    <td width="15%"><input name="invests/total_2" id="total_2" value="<x:out select="$xmlData/data/invests/total_2" />" class="gray input_text"  disabled style="text-align:right;width:80%;" label="计划新增投资支出中申请资助经费合计" onfocus="InitInput.setNumber(this,7,4,2)" /></td>
					<td width="10%"><input name="invests/total_3" id="total_3" value="<x:out select="$xmlData/data/invests/total_3" />" class="gray input_text"  disabled  style="text-align:right;width:80%;" label="计划新增投资支出中2013年经费合计" onfocus="InitInput.setNumber(this,7,4,2)" /></td>
					<td width="10%"><input name="invests/total_4" id="total_4" value="<x:out select="$xmlData/data/invests/total_4" />" class="gray input_text"  disabled style="text-align:right;width:80%;" label="计划新增投资支出中2014年经费合计" onfocus="InitInput.setNumber(this,7,4,2)" /></td>
					<td width="10%"><input name="invests/total_5" id="total_5" value="<x:out select="$xmlData/data/invests/total_5" />" class="gray input_text"  disabled style="text-align:right;width:80%;" label="计划新增投资支出中2015年经费合计" onfocus="InitInput.setNumber(this,7,4,2)" /></td>
                   </tr>
                    </table>
					
					<table width="98%" align="center">
					<tr ><td>
					<input class="button" name="cmdAddbefore" type=button value="添加" onclick="if(checkTabLimit('tblInvests',20,'计划新增投资支出最多只能填写20条')){addNewRow('tblInvests');showDateTag('tblInvests');}try{top.resizeFrame();}catch(e){};">
					<input class="button" name="cmdMovePrev" type=button value="上移" onclick="movePrev('tblInvests','selInvests')">
					<input class="button" name="cmdMoveNext" type=button value="下移" onclick="moveNext('tblInvests','selInvests')">
					<input class="button" name="cmddel" type=button  value="删除" onclick="deleteSelectedRow('tblInvests','计划新增投资支出');countTable('tblInvests','total_5',7);countTable('tblInvests','total_4',6);countTable('tblInvests','total_3',5);countTable('tblInvests','total_2',4);countTable('tblInvests','total_1',3);">
					</td></tr>
	</table>	



<script type="text/javascript">
$(document).ready(function() {
var prp_version=$("#prp_version").text();

if(prp_version==""||prp_version==null){
	$("#budgetsMsg").find(":input").each(function(){
	$(this).val("0.00");	
	});
	
	$("#budgetsMsg1").find(":input").each(function(){
		$(this).val("0.00");	
		});
	
	$("#budgetsMsg2").find(":input").each(function(){
		$(this).val("0.00");	
		});
	
	
}

$("#source_city").attr("disabled",true);
$("#source_area").attr("disabled",true);
$("#source_city").addClass("gray");
$("#source_area").addClass("gray"); 
	
});

function synchro(){
	var source_apply = $("#source_apply").val();
	var source_total = $("#source_total").val();
	var source_already = $("#source_already").val();
	var source_add = $("#source_add").val();
	
	$("#sqje").val(formatVal2(source_apply));
	$("#plan_total").val(formatVal2(source_total));
	$("#finish_budget").val(formatVal2(source_already));
	$("#plan_add_budget").val(formatVal2(source_add));
}


function setSource(val){
	var areaNo = $("input[name$='area_no']").val();
	var flag_shizhi = $("#flag_shizhi").val();
	if(flag_shizhi ==  1){
		if((formatNumberAuto(val+"", 7, 4, 2)*10000)%10000!=0)
			$("#source_city").val(formatNumberAuto(val+"0000", 7, 4, 2));
		else
			$("#source_city").val(formatNumberAuto(val+".0000", 7, 4, 2));
		$("#source_area").val("0.00");
	}else{
		if(areaNo == '320202' || areaNo == '320204' || areaNo == '320203'){
			
		if((formatNumberAuto(val*0.8+"", 7, 4, 2)*10000)%10000!=0)
			$("#source_city").val(formatNumberAuto(val*0.8+"0000", 7, 4, 2));
		else
			$("#source_city").val(formatNumberAuto(val*0.8+".0000", 7, 4, 2));
		
		
		if((val*10000-formatNumberAuto(val*0.8+"", 7, 4, 2)*10000)%10000!=0){
		 	$("#source_area").val(formatNumberAuto(((val*10000-formatNumberAuto(val*0.8+"", 7, 4, 2)*10000)/10000)+"0000", 7, 4, 2));
		}else{
			$("#source_area").val(formatNumberAuto(((val*10000-formatNumberAuto(val*0.8+"", 7, 4, 2)*10000)/10000)+".0000", 7, 4, 2));
		}
		}else if(areaNo == '320205' || areaNo == '320206' || areaNo == '320211' || areaNo == '320212'){
			//$("#source_city").val(formatNumberAuto(val*0.5+"", 7, 4, 2));
			if((formatNumberAuto(val*0.5+"", 7, 4, 2)*10000)%10000!=0)
				$("#source_city").val(formatNumberAuto(val*0.5+"0000", 7, 4, 2));
			else
				$("#source_city").val(formatNumberAuto(val*0.5+".0000", 7, 4, 2));
			
			if((val*10000-formatNumberAuto(val*0.5+"", 7, 4, 2)*10000)%10000!=0){
				$("#source_area").val(formatNumberAuto(((val*10000-formatNumberAuto(val*0.5+"", 7, 4, 2)*10000)/10000)+"0000", 7, 4, 2));
			}else
				$("#source_area").val(formatNumberAuto(((val*10000-formatNumberAuto(val*0.5+"", 7, 4, 2)*10000)/10000)+".0000", 7, 4, 2));
		}else if(areaNo == '320281' || areaNo == '320282'){
			//$("#source_city").val(formatNumberAuto(val*0.2+"", 7, 4, 2));
			if((formatNumberAuto(val*0.2+"", 7, 4, 2)*10000)%10000!=0)
				$("#source_city").val(formatNumberAuto(val*0.2+"0000", 7, 4, 2));
			else
				$("#source_city").val(formatNumberAuto(val*0.2+".0000", 7, 4, 2));
			if((val*10000-formatNumberAuto(val*0.2+"", 7, 4, 2)*10000)%10000!=0){
				$("#source_area").val(formatNumberAuto(((val*10000-formatNumberAuto(val*0.2+"", 7, 4, 2)*10000)/10000)+"0000", 7, 4, 2));
			}else{
				$("#source_area").val(formatNumberAuto(((val*10000-formatNumberAuto(val*0.2+"", 7, 4, 2)*10000)/10000)+".0000", 7, 4, 2));
				
			}
		}
	}
}

</script>
